package com.yswl.pri.fun;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import yswl.com.klibrary.util.DateJsonDeserializer;

/**
 * Created by wulee on 2017/9/4 17:18
 */

public class JokeInfo {

    /**
     * title : 唉，都是泪啊
     * content : 　　在街上看到一妹子，第一眼，哇好漂亮，第二眼真他妈漂亮！<br/><br/>　　第三眼哪有这么漂亮的妹子啊！第四眼他跟一光头大叔上奥迪走了，<br/><br/>　　我扶着我的自行车在风中沉默了好久...
     * poster :
     * url : http://www.laifudao.com/wangwen/78732.htm
     */

    private String title;
    private String content;
    private String poster;
    private String url;

    public static ArrayList<JokeInfo> jsonToList(String json) {
        JSONArray objarray = null;
        try {
            objarray = new JSONArray(json);
        } catch (JSONException e) {
            return null;
        }
        Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new DateJsonDeserializer()).create();
        ArrayList<JokeInfo> list = gson.fromJson(objarray.toString(), new TypeToken<List<JokeInfo>>() {
        }.getType());
        return list;
    }


    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public String getJokeContent() {
        String curr = getContent().replace("<br/>", "\n");
        return curr;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getPoster() {
        return poster;
    }

    public void setPoster(String poster) {
        this.poster = poster;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
